import request from '@/utils/request'

export function create(data) {
  return request({
    url: '/api/v1/PermissionUser/Create',
    method: 'post',
    data
  })
}

export function deleteRecord(data) {
  return request({
    url: '/api/v1/PermissionUser/Delete',
    method: 'delete',
    data
  })
}

export function update(data) {
  return request({
    url: '/api/v1/PermissionUser/Update',
    method: 'post',
    data
  })
}

export function UpdateBasics(data) {
  return request({
    url: '/api/v1/PermissionUser/UpdateBasics',
    method: 'post',
    data
  })
}

export function getList(data, pagination) {
  if (pagination) {
    data["pageIndex"] = pagination.pageIndex;
    data["pageSize"] = pagination.pageSize;
  }
  return request({
    url: '/api/v1/PermissionUser/GetList',
    method: 'get',
    params: data
  })
}
export const getUserListNoPage = params => request('/api/v1/PermissionUser/GetUserListNoPage', { params: params });
export const userDetail = params => request('/api/v1/PermissionUser/Get', { params: params });
export const getCurrentUserInfo = params => request('/api/v1/PermissionUser/GetInfo', { params: params });
export function findUserMenu() {
  return request({
    url: '/api/v1/PermissionUser/FindUserMenu',
    method: 'get',
    params: { appKey: window.EnvConfig.VUE_APP_KEY }
  })
}

// 禁用用户
export const disableByIdAsync = data => request.post('/api/v1/PermissionUser/DisableById', data);

// 启用用户
export const enableByIdAsync = data => request.post('/api/v1/PermissionUser/EnableById', data);
// 更新密码
export const UpdatePassword = data => request.post('/api/v1/PermissionUser/UpdatePassword', data);

export function getUserList(data) {
  return request({
    url: '/api/v1/PermissionUser/getUserList',
    method: 'post',
    data: data
  })
}
